{% load static %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>天天生鲜-用户中心</title>
	<link rel="stylesheet" type="text/css" href="{% static 'css/reset.css' %}">
	<link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
</head>
<body>
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到天天生鲜!</div>
			<div class="fr">
				<div class="login_info fl">
					欢迎您：<em>张 山</em>
				</div>
				<div class="login_btn fl">
                    {% if user.name %}
                        <span style="color: black">欢迎您：</span><a href="{% url 'hmsx:info' %}" style="color: blue">{{ user.name }}</a>
                        <span>|</span>
					    <a href="{% url 'hmsx:dele' %}">退出</a>
                    {% else %}
                        <a href="{% url 'hmsx:login' %}">登录</a>
                    {% endif %}
					<span>|</span>
					<a href="{% url 'hmsx:register' %}">注册</a>
				</div>
				<div class="user_link fl">
					<span>|</span>
					<a href="{% url 'hmsx:info' %}">用户中心</a>
					<span>|</span>
					<a href="cart.html">我的购物车</a>
					<span>|</span>
					<a href="user_center_order.html">我的订单</a>
				</div>
			</div>
		</div>		
	</div>

	<div class="search_bar clearfix">
		<a href="{% url 'hmsx:index' %}" class="logo fl"><img src="{% static 'img/logo.png' %}"></a>
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
		<div class="search_con fr">
			<input type="text" class="input_text fl" name="" placeholder="搜索商品">
			<input type="button" class="input_btn fr" name="" value="搜索">
		</div>		
	</div>

	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a href="user_center_info.html" class="active">· 个人信息</a></li>
				<li><a href="user_center_order.html">· 全部订单</a></li>
				<li><a href="user_center_site.html">· 收货地址</a></li>
			</ul>
		</div>
		<div class="right_content clearfix">
            <div class="info_con clearfix">
                <h3 class="common_title2">基本信息</h3>
                    <ul class="user_info_list">
                        <li><span>账&emsp;&emsp;号：</span>{{ user.username }}</li>
                        <li><span>用&nbsp;&nbsp;户&nbsp;&nbsp;名：</span>{{ user.name }}&emsp;<input type="button" value="修改"></li>
                        <li><span>邮&emsp;&emsp;箱：</span>{{ user.email }}<div id="active_msg" style="display:none;float: right;margin-right:500px;color: #7bff4b"></div></li>
                        {% if user.activate  %}
                            <li><span>激活状态：</span><p style="color: green">已激活</p></li>
                        {% else %}
                            <li><span>激活状态：</span><p style="color: red">未激活&emsp;&emsp;<button id="active">激活</button></p></li>
                        {% endif %}
                        {% if user.iphon %}
                            <li><span>联系方式：</span>{{ user.iphon }}</li>
                        {% else %}
                            <li><span>联系方式：</span>
                                <form action="{% url 'hmsx:info' %}" method="post">
                                    {% csrf_token %}
                                    <input type="text" id="phone" name="phone">
                                    <span id="error_phone" class="error" style="float: right;margin-right: 55%;"></span>
                                    <input type="submit" id="submit" value="绑定">
                                </form>
                            </li>
                        {% endif %}
                        <li><span>收货地址：</span></li>
                    </ul>
                </div>
		</div>
	</div>

	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>


    <script src="{% static 'js/jquery-1.12.4.min.js' %}"></script>
    <script type="text/javascript">
        $(function () {
            var phone = $('#phone');
            var submitBtn = $("#submit");
            var ok = true;
            submitBtn.click(function () {
                if (phone.val()){
                    if (/^((1[3456789][0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$/.test(phone.val())){
                        ok = true
                    }else{
                        $('#error_phone').css({'display': 'block', 'color': 'red'}).html('非法手机号');
                        ok = false
                    }
                } else if (phone.val()=== '' || phone.val().length===0 ){
                        ok = false
                }
                return ok
            });
            phone.click(function () {
                $('#error_phone').css('display', 'none')
            });
            $('#active').click(function () {
                $.ajax({
                    url :"{% url 'hmsx:regis' %}",
                    type:'post',
                    success:function (data) {
                        if (data['result']){
                           $('#active_msg').css('display','inline-block').html(data['result'])
                        }else {
                            $('#active_msg').css('display','inline-block').html('发送失败')
                        }

                    }
                })
            })
        })
    </script>
</body>
</html>